﻿<%@ Assembly Name="JM.JCY.SharePointComponent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a3f76d78e78426e2" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SiteNewsfeedUserControl.ascx.cs"
    Inherits="NCS.OCP.SharePointComponent.Newsfeed.SiteNewsfeed.SiteNewsfeedUserControl" %>


<script type="text/javascript" src="/_layouts/JM.JCY.Resource/scripts/OCPNewsfeed.js"></script>
<script runat="server">
    protected String GetStaffId()
    {
        string staffid = "0";
        if (NCS.IConnect.ApplicationContexts.ApplicationContext.Current.GetKeyValue("userId") != null)
        {
            staffid = NCS.IConnect.ApplicationContexts.ApplicationContext.Current.GetKeyValue("userId").ToString();
        }
        return staffid;
    }
    protected string GetAppTypeURL()
    {
        return SPContext.Current.Web.ServerRelativeUrl; 
    }

    protected string GetAppType()
    {
        string appType = "";
        if (NCS.IConnect.ApplicationContexts.ApplicationContext.Current.GetKeyValue("NewsfeedAppType") != null)
        {
            appType = NCS.IConnect.ApplicationContexts.ApplicationContext.Current.GetKeyValue("NewsfeedAppType").ToString();
        }
        return appType;
    }

    protected int GetAppId()
    {
        int appid = 0;
        string appType = GetAppType();
        if (appType.Equals(JM.JCY.Common.JCYConstant.PhotoAlbum.ApplicationTypeName.PublicName))
        {
            appid = 0;
        }
        else if (appType.Equals(JM.JCY.Common.JCYConstant.PhotoAlbum.ApplicationTypeName.PersonalName))
        {
            appid = Convert.ToInt32(GetStaffId());
        }
        else
        {
            if (NCS.IConnect.ApplicationContexts.ApplicationContext.Current.GetKeyValue("NewsfeedAppId") != null)
            {
                appid = Convert.ToInt32(NCS.IConnect.ApplicationContexts.ApplicationContext.Current.GetKeyValue("NewsfeedAppId"));
            }
        }
        return appid;
    }
    
    protected string GetCommentLimitedLength()
    {
        return "50";
    }
    
</script>
<script id="newsfeedTemplate" type="text/x-jquery-tmpl"> 
{{if staff}}
    <div id=feedpost_${id} class="newsfeedPost">
      <img src='${staff.imgUrl}' class="newsfeedPostImg"/>	<input type="hidden" value="${lastestUpdatedTime}" id="lastestUpdateTime_${id}" class="hiddenCss"/>

  <div class="newsfeedPostName">
    <a class="newsfeedPostName_a" href="/PersonalSite/PersonalPages/PublicUser.aspx?StaffId=${staff.id}">${staff.name}</a>
  </div>
  <div class="newsfeedPostContent">
    {{html content}}
    <div class="newsfeedPostFooter">
      <div class="timeAgo">{{html JCY.Utilities.convertJsonDate($data.timestamp, 'timeago') }}</div> · 
      <span class="comment">评论</span> 
      {{if creator==<%=GetStaffId() %>}} · 
        <span class="deleteFeedpost" id="delete_${id}">删除</span>
      {{/if}}     
    </div>
  </div>
  <div class="moreCommentList" id="moreCommentList_${id}"></div><input type="hidden" value="0" id="commentCount_${id}" />
  <div id=commentList_${id}></div>
  <div id=newFeedcomment_${id} class="newFeedcomment">
    <span class="newFeedCommentContent">
      <input type="text" value="请输入..." class="newFeedcommentInput" /> 
      <img src="/_layouts/JM.JCY.Resource/images/newsfeedok.png" class="commentSubmit"/>
    </span>
  </div> 
  <hr />
</div>
  {{/if}}
</script>

<script id="commentTemplate" type="text/x-jquery-tmpl"> 
<div id=feedComment_${commentId} class="feedComment"> 
 <img src='${staff.imgUrl}' class="commentPostImg"/>
    <div class="feedCommentStaff">
	<a class="feedCommentName_a" href="/PersonalSite/PersonalPages/PublicUser.aspx?StaffId=${staff.id}">${staff.name}</a>
  </div>
  <div class="feedCommentContent">
 <span id="commentContent_${commentId}">{{html content}}</span>

 {{if showMoreLink && showMoreLink=='true'}}
   <a id="viewMoreComment_${commentId}" moreContent="${moreContent}" class="moreFeedComment">...全部</a>
 {{/if}}

    <div class="newsfeedPostFooter">
      <div class="timeAgo">{{html JCY.Utilities.convertJsonDate($data.timestamp, 'timeago') }}</div>  

      {{if staff.id==<%=GetStaffId() %>}}
·
      <span class="deleteComment" id="deleteComment_${commentId}">删除</span>

      {{/if}}
    </div>
  </div>
</div>
</script>

<script id="moreCommentTemplate" type="text/x-jquery-tmpl"> 
{{if actualCount>30}}  
    <div class="moreCommentsContainer" id="moreComments_${postId}">
        <div class="moreComments">
            <a href="<% =GetAppTypeURL() %>/_layouts/SharePointComponent/ViewAllComments.aspx?feedPostId=${postId}">
                <span class="commentDesc">显示所有评论</span> (<span id="divCommentCount_${postId}"></span>) <input type="hidden" value="up" id="slideStatus_${postId}"/>
            </a>
        </div>
    </div>
{{/if}}

{{if actualCount<=30 && actualCount>3}}
       <div class="moreCommentsContainer" id="moreComments_${postId}">
        <div class="moreComments">
            <a class="setThirty">
             <span class="commentDesc">显示所有评论</span> (<span id="divCommentCount_${postId}"></span>) <input type="hidden" value="up" id="slideStatus_${postId}"/>
            </a>
        </div>
    </div>
{{else}}
{{/if}}
</script>

<script id="viewMoreFeedPostTemplate" type="text/x-jquery-tmpl">

{{if postCount}}
    {{if postCount>10}}
        <div id="loadMoreFeed">查看更多</div>  
    {{/if}}
{{/if}}
</script>
<script type="text/javascript">

    $(document).ready(function () {

        $.support.cors = true;

        $("#newsfeedWebPartContainer").fadeIn("slow");

        LoadNewsfeed('<% =GetStaffId() %>', '<% =GetAppType() %>', "<% =GetAppId() %>", 30, "<%=GetCommentLimitedLength() %>", $("#newsfeedList"));

        RegisterEvent('<% =GetStaffId() %>', "<% =GetAppType() %>", "<% =GetAppId() %>", "<%=GetCommentLimitedLength() %>", 25, 10);

    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#td_Education").click(function () {
            $("#divEducation").slideToggle("slow", function callback() {
                if ($("#divEducation").is(":visible")) {
                    $("#imgBtnEducation").attr("src", "/_Layouts/JM.JCY.Resource/images/toggle_collapse.png");
                }
                else {
                    $("#imgBtnEducation").attr("src", "/_Layouts/JM.JCY.Resource/images/toggle_expand.png");
                }
            });
        });
  $("#td_Education2").click(function () {
            $("#divEducation").slideToggle("slow", function callback() {
                if ($("#divEducation").is(":visible")) {
                    $("#imgBtnEducation").attr("src", "/_Layouts/JM.JCY.Resource/images/toggle_collapse.png");
                }
                else {
                    $("#imgBtnEducation").attr("src", "/_Layouts/JM.JCY.Resource/images/toggle_expand.png");
                }
            });
        });
 
    });

</script>
 <table class="webpart" width="99%" cellpadding="0" cellspacing="0">
   		<tr>
                        <th valign="middle" align="left" id="td_Education" width="50%" class="title" style="cursor: pointer">
                             <img src="/_layouts/JM.JCY.Resource/images/newsfeedlogo.png" width="28" />  小组微博
                        </th>
                        <th id="td_Education2" class="title" align="right" width="50%" style="cursor: pointer">
                            <img class="toggle" id="imgBtnEducation" src="/_layouts/JM.JCY.Resource/images/toggle_expand.png" />
                        </th>
                    </tr>


                            
                                
                                <tr>
                                    <td colspan=2>
                                        <div id="divEducation" visible="false" style="display: none;">
                                         <table width="95%" class="form">
                                      
                                            <tr>
                                               <td>

<div id="newsfeedWebPartContainer">
    <input type="hidden" id="curBiggestId" value="0" />
    <input type="hidden" id="curSmallestId" value="0" />
    <input type="hidden" id="feedPostIdCollect" />
    <input type="hidden" id="newFeedPostIdCollect" />
    <input type="hidden" id="HiddenLastNewsfeedTime" value="" />
    <input type="hidden" id="HiddenCommentPostId" />

    <div id="newsfeedContainer">
        <div id="newsfeedInputContainer">
            <input type="text" value="你想谈论..." class="newsfeedInput" />
            <img src="/_layouts/JM.JCY.Resource/images/newsfeedok.png" alt="" class="newsfeedSubmit" />
        </div>
        
        <div id="loadingContainer">
            <img src="/_layouts/JM.JCY.Resource/images/loading.gif" alt="" />正在运行，请稍等...
        </div>

        <div id="newsfeedList"></div>
       
        <div id="loadMoreFeed">查看更多</div>
    </div>
</div>
   </td>
                                            </tr>
                                         </table>
                                        
                                           
                                        </div>
                                    </td>
                                </tr>
                            </table>